return c |
print(word) |
word = getHello() |
def getHello(): |
c = "hello" |
    return c |
print(word) |
word = getHello() |
def getHello(): |
    c = "hello" |
1 | def getHello(): |
2 |     c = "hello" |
3 |     return c |
4 | |
5 | word = getHello() |
6 | print(word) |
n = n + 2 |
print(b) |
a = 2 |
def addTwo(n): |
b = addTwo(a) |
return n |
    n = n + 2 |
print(b) |
a = 2 |
def addTwo(n): |
b = addTwo(a) |
    return n |
1 | def addTwo(n): |
2 |     n = n + 2 |
3 |     return n |
4 | |
5 | a = 2 |
6 | b = addTwo(a) |
7 | print(b) |
s = s + "?" |
print(s) |
def question(s): |
s = question(s) |
return s |
s = "You okay" |
    s = s + "?" |
print(s) |
def question(s): |
s = question(s) |
    return s |
s = "You okay" |
1 | def question(s): |
2 |     s = s + "?" |
3 |     return s |
4 | |
5 | s = "You okay" |
6 | s = question(s) |
7 | print(s) |
def twoWord(a): |
print(b) |
return a |
a = a + a |
s = "word" |
b = twoWord(s) |
def twoWord(a): |
print(b) |
    return a |
    a = a + a |
s = "word" |
b = twoWord(s) |
1 | def twoWord(a): |
2 |     a = a + a |
3 |     return a |
4 | |
5 | s = "word" |
6 | b = twoWord(s) |
7 | print(b) |
b = twoWord(s) |
c = twoWord(b) |
print(c) |
s = "word" |
a = a + a |
return a |
def twoWord(a): |
b = twoWord(s) |
c = twoWord(b) |
print(c) |
s = "word" |
    a = a + a |
    return a |
def twoWord(a): |
1 | def twoWord(a): |
2 |     a = a + a |
3 |     return a |
4 | |
5 | s = "word" |
6 | b = twoWord(s) |
7 | c = twoWord(b) |
8 | print(c) |
def isEven(n): |
else: |
a = 10 |
print(a) |
e = isEven(a) |
if n % 2 == 0: |
return True |
return False |
def isEven(n): |
    else: |
a = 10 |
print(a) |
e = isEven(a) |
    if n % 2 == 0: |
        return True |
        return False |
1 | def isEven(n): |
2 |     if n % 2 == 0: |
3 |         return True |
4 |     else: |
5 |         return False |
6 | |
7 | a = 10 |
8 | e = isEven(a) |
9 | print(a) |
for x in range(len(string)): |
def howMany(string,letter): |
count += 1 |
return count |
count = 0 |
print(a) |
a = howMany("hello","l") |
if string[x] == letter: |
    for x in range(len(string)): |
def howMany(string,letter): |
            count += 1 |
    return count |
    count = 0 |
print(a) |
a = howMany("hello","l") |
        if string[x] == letter: |
1 | def howMany(string,letter): |
2 |     count = 0 |
3 |     for x in range(len(string)): |
4 |         if string[x] == letter: |
5 |             count += 1 |
6 |     return count |
7 | |
8 | a = howMany("hello","l") |
9 | print(a) |
newArr = [] |
newArr.append(item) |
print(a) |
def reverseArray(arr): |
return newArr |
item = arr[len(arr) - 1 - x] |
a = reverseArray([1,2,3,4]) |
for x in range(len(arr)): |
    newArr = [] |
        newArr.append(item) |
print(a) |
def reverseArray(arr): |
    return newArr |
        item = arr[len(arr) - 1 - x] |
a = reverseArray([1,2,3,4]) |
    for x in range(len(arr)): |
1 | def reverseArray(arr): |
2 |     newArr = [] |
3 |     for x in range(len(arr)): |
4 |         item = arr[len(arr) - 1 - x] |
5 |         newArr.append(item) |
6 |     return newArr |
7 | |
8 | a = reverseArray([1,2,3,4]) |
9 | print(a) |
return count |
for x in range(len(arr)): |
count = 0 |
def sumArray(arr): |
r = sumArray([2,3,2,3,2]) |
print(r) |
count = count + arr[x] |
    return count |
    for x in range(len(arr)): |
    count = 0 |
def sumArray(arr): |
r = sumArray([2,3,2,3,2]) |
print(r) |
        count = count + arr[x] |
1 | def sumArray(arr): |
2 |     count = 0 |
3 |     for x in range(len(arr)): |
4 |         count = count + arr[x] |
5 |     return count |
6 | r = sumArray([2,3,2,3,2]) |
7 | print(r) |
def moreSpaces(s): |
for x in range(len(s)): |
r = moreSpaces("This is a test") |
print(r) |
else: |
if s[x] == " ": |
es = es + " " |
return es |
es = "" |
es = es + s[x] |
def moreSpaces(s): |
    for x in range(len(s)): |
r = moreSpaces("This is a test") |
print(r) |
        else: |
        if s[x] == " ": |
            es = es + " " |
    return es |
    es = "" |
            es = es + s[x] |
1 | def moreSpaces(s): |
2 |     es = "" |
3 |     for x in range(len(s)): |
4 |         if s[x] == " ": |
5 |             es = es + " " |
6 |         else: |
7 |             es = es + s[x] |
8 |     return es |
9 | |
10 | r = moreSpaces("This is a test") |
11 | print(r) |
return True |
if s[x] != "0" and s[x] != "1": |
return False |
print(r) |
#Remember when return is executed nothing else runs, if it reaches here it has only seen 1s or 0s |
for x in range(len(s)): |
def isBinary(s): |
r = isBinary("10101") |
    return True |
        if s[x] != "0" and s[x] != "1": |
            return False |
print(r) |
    #Remember when return is executed nothing else runs, if it reaches here it has only seen 1s or 0s |
    for x in range(len(s)): |
def isBinary(s): |
r = isBinary("10101") |
1 | def isBinary(s): |
2 |     for x in range(len(s)): |
3 |         if s[x] != "0" and s[x] != "1": |
4 |             return False |
5 |     #Remember when return is executed nothing else runs, if it reaches here it has only seen 1s or 0s |
6 |     return True |
7 | |
8 | r = isBinary("10101") |
9 | print(r) |
a = howManyZeroes(200300) |
return count |
else: |
def howManyZeroes(num): |
num = str(num) |
count = 0 |
print(a) |
break |
char = num[len(num)-1-x] |
if char == "0": |
for x in range(len(num)): |
count = count + 1 |
a = howManyZeroes(200300) |
    return count |
        else: |
def howManyZeroes(num): |
    num = str(num) |
    count = 0 |
print(a) |
            break |
        char = num[len(num)-1-x] |
        if char == "0": |
    for x in range(len(num)): |
            count = count + 1 |
1 | def howManyZeroes(num): |
2 |     num = str(num) |
3 |     count = 0 |
4 |     for x in range(len(num)): |
5 |         char = num[len(num)-1-x] |
6 |         if char == "0": |
7 |             count = count + 1 |
8 |         else: |
9 |             break |
10 |     return count |
11 | |
12 | a = howManyZeroes(200300) |
13 | print(a) |
return arr[0] |
def printMultiplePeople(arr): |
if len(arr) == 0: |
arr = ["Bob","Fred"] |
print(z) |
return commas + " and " + arr[-1] |
return "" |
z = printMultiplePeople(arr) |
commas = ", ".join(arr[:-1]) |
elif len(arr) == 1: |
else: |
        return arr[0] |
def printMultiplePeople(arr): |
    if len(arr) == 0: |
arr = ["Bob","Fred"] |
print(z) |
        return commas + " and " + arr[-1] |
        return "" |
z = printMultiplePeople(arr) |
        commas = ", ".join(arr[:-1]) |
    elif len(arr) == 1: |
    else: |
1 | def printMultiplePeople(arr): |
2 |     if len(arr) == 0: |
3 |         return "" |
4 |     elif len(arr) == 1: |
5 |         return arr[0] |
6 |     else: |
7 |         commas = ", ".join(arr[:-1]) |
8 |         return commas + " and " + arr[-1] |
9 | |
10 | arr = ["Bob","Fred"] |
11 | z = printMultiplePeople(arr) |
12 | print(z) |
return False |
if isfloat(results[x]) == answers[x]: |
return False |
if num.count(".") == 1: |
answers = [True,True,True,False,False,True,True,False,True,False] |
if num.isdigit() == False: |
num = str(num) |
print("Fail") |
num = num.replace(".","") |
elif num.count(".") > 1: |
num = num[1:] |
return True |
for x in range(len(results)): |
def isfloat(num): |
results = ["1","2.4","-2.4","a","a.5","-3","4.0","ab.cd","1000","2.4.1"] |
else: |
if num[0] == "-": |
print("Pass") |
        return False |
  if isfloat(results[x]) == answers[x]: |
        return False |
    if num.count(".") == 1: |
answers = [True,True,True,False,False,True,True,False,True,False] |
    if num.isdigit() == False: |
    num = str(num) |
    print("Fail") |
        num = num.replace(".","") |
    elif num.count(".") > 1: |
        num = num[1:] |
    return True |
for x in range(len(results)): |
def isfloat(num): |
results = ["1","2.4","-2.4","a","a.5","-3","4.0","ab.cd","1000","2.4.1"] |
  else: |
    if num[0] == "-": |
    print("Pass") |
1 | def isfloat(num): |
2 |     num = str(num) |
3 |      |
4 |     if num.count(".") == 1: |
5 |         num = num.replace(".","") |
6 |     elif num.count(".") > 1: |
7 |         return False |
8 |      |
9 |     if num[0] == "-": |
10 |         num = num[1:] |
11 |      |
12 |     if num.isdigit() == False: |
13 |         return False |
14 |      |
15 |     return True |
16 | |
17 | results = ["1","2.4","-2.4","a","a.5","-3","4.0","ab.cd","1000","2.4.1"] |
18 | answers = [True,True,True,False,False,True,True,False,True,False] |
19 | |
20 | for x in range(len(results)): |
21 |   if isfloat(results[x]) == answers[x]: |
22 |     print("Pass") |
23 |   else: |
24 |     print("Fail") |
s = s + arr[x][y] |
s = s + "\n" |
s = "" |
for x in range(len(arr)): |
def print2DArray(arr): |
for y in range(len(arr[x])): |
print(string) |
return s |
example = [[".",".","."],["-","-","-"],["@","@","@"]] |
string = print2DArray(example) |
            s = s + arr[x][y] |
        s = s + "\n" |
    s = "" |
    for x in range(len(arr)): |
def print2DArray(arr): |
        for y in range(len(arr[x])): |
print(string) |
    return s |
example = [[".",".","."],["-","-","-"],["@","@","@"]] |
string = print2DArray(example) |
1 | def print2DArray(arr): |
2 |     s = "" |
3 |     for x in range(len(arr)): |
4 |         for y in range(len(arr[x])): |
5 |             s = s + arr[x][y] |
6 |         s = s + "\n" |
7 |     return s |
8 | example = [[".",".","."],["-","-","-"],["@","@","@"]] |
9 | string = print2DArray(example) |
10 | print(string) |
for x in range(len(arr)): |
newArray = getColumn(example,1) |
example = [["1","2","3"],["4","5","6"],["7","8","9"]] |
def getColumn(arr,n): |
newarr = [] |
newarr.append(arr[x][n]) |
return newarr |
print(newArray) |
    for x in range(len(arr)): |
newArray = getColumn(example,1) |
example = [["1","2","3"],["4","5","6"],["7","8","9"]] |
def getColumn(arr,n): |
    newarr = [] |
        newarr.append(arr[x][n]) |
    return newarr |
print(newArray) |
1 | def getColumn(arr,n): |
2 |     newarr = [] |
3 |     for x in range(len(arr)): |
4 |         newarr.append(arr[x][n]) |
5 |     return newarr |
6 | |
7 | example = [["1","2","3"],["4","5","6"],["7","8","9"]] |
8 | newArray = getColumn(example,1) |
9 | print(newArray) |
newarr = [] |
string = string + char |
es = "" |
sa = splitArr("this is a test string"," ") |
#Add an extra char to the end so the final item is added |
if string[x] == char: |
newarr.append(es) |
es = es + string[x] |
return newarr |
def splitArr(string,char): |
else: |
print(sa) |
for x in range(len(string)): |
es = "" |
    newarr = [] |
    string = string + char |
            es = "" |
sa = splitArr("this is a test string"," ") |
    #Add an extra char to the end so the final item is added |
        if string[x] == char: |
            newarr.append(es) |
            es = es + string[x] |
    return newarr |
def splitArr(string,char): |
        else: |
print(sa) |
    for x in range(len(string)): |
    es = "" |
1 | def splitArr(string,char): |
2 |     #Add an extra char to the end so the final item is added |
3 |     string = string + char |
4 |     newarr = [] |
5 |     es = "" |
6 |     for x in range(len(string)): |
7 |         if string[x] == char: |
8 |             newarr.append(es) |
9 |             es = "" |
10 |         else: |
11 |             es = es + string[x] |
12 |     return newarr |
13 | |
14 | sa = splitArr("this is a test string"," ") |
15 | print(sa) |